package com.tencent.mm.opensdk.openapi;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import com.tencent.mm.opensdk.utils.Log;
import com.tencent.mm.opensdk.utils.TencentColumns;

import java.util.*;

class MMSharedPreferences   implements SharedPreferences
{
  private static final String TAG = "MicroMsg.SDK.SharedPreferences";
  private final ContentResolver cr;
  private final String[] columns = { "_id", "key", "type", "value" };
  private final HashMap<String, Object> values = new HashMap();
  private REditor editor = null;
  
  public MMSharedPreferences(Context paramContext)
  {
    this.cr = paramContext.getContentResolver();
  }
  
  private Object getValue(String paramString)
  {
    try
    {
   Cursor cursor= this.cr.query(TencentColumns.CONTENT_URI, this.columns, "key = ?", new String[] { paramString }, null);
      if (cursor== null) {
        return null;
      }
      int i = cursor.getColumnIndex("type");
      int j = cursor.getColumnIndex("value");
      Object localObject = null;
      if (cursor.moveToFirst()) {
        localObject = TencentColumns.parseValue(cursor.getInt(i), cursor.getString(j));
      }
      cursor.close();
      return localObject;
    }
    catch (Exception e)
    {
      Log.e("MicroMsg.SDK.SharedPreferences", "getValue exception:" + e.getMessage());
    }
    return null;
  }
  
  public Map<String, ?> getAll()
  {
    try
    {
      Cursor localCursor;
      if ((localCursor = this.cr.query(TencentColumns.CONTENT_URI, this.columns, null, null, null)) == null) {
        return null;
      }
      int i = localCursor.getColumnIndex("key");
      int j = localCursor.getColumnIndex("type");
      int k = localCursor.getColumnIndex("value");
      while (localCursor.moveToNext())
      {
        Object localObject = TencentColumns.parseValue(localCursor.getInt(j), localCursor.getString(k));
        this.values.put(localCursor.getString(i), localObject);
      }
      localCursor.close();
      return this.values;
    }
    catch (Exception localException)
    {
      Log.e("MicroMsg.SDK.SharedPreferences", "getAll exception:" + localException.getMessage());
    }
    return this.values;
  }
  
  public String getString(String paramString1, String paramString2)
  {

    Object o = getValue(paramString1);
    if (((o) != null) && ((o instanceof String))) {
      return (String)paramString1;
    }
    return paramString2;
  }
  
  public int getInt(String paramString, int paramInt)
  {

    Object o = getValue(paramString);
    if (( o != null) && ((o instanceof Integer))) {
      return ((Integer)o).intValue();
    }
    return paramInt;
  }
  
  public long getLong(String paramString, long paramLong)
  {
    Object value = getValue(paramString);
    if ((value != null) && ((value instanceof Long))) {
      return ((Long)value).longValue();
    }
    return paramLong;
  }
  
  public float getFloat(String paramString, float paramFloat)
  {
    Object value = getValue(paramString);
    if ((value != null) && ((value instanceof Float))) {
      return ((Float)value).floatValue();
    }
    return paramFloat;
  }
  
  public boolean getBoolean(String paramString, boolean paramBoolean)
  {


    Object value = getValue(paramString);

    if ((value!= null) && ((value instanceof Boolean))) {
      return ((Boolean)value).booleanValue();
    }
    return paramBoolean;
  }
  
  public boolean contains(String paramString)
  {
    return getValue(paramString) != null;
  }
  
  public SharedPreferences.Editor edit()
  {
    if (this.editor == null) {
      this.editor = new REditor(this.cr);
    }
    return this.editor;
  }
  
  public void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener paramOnSharedPreferenceChangeListener) {}
  
  public void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener paramOnSharedPreferenceChangeListener) {}
  
  public Set<String> getStringSet(String paramString, Set<String> paramSet)
  {
    return null;
  }
  
  private static class REditor
    implements SharedPreferences.Editor
  {
    private Map<String, Object> values = new HashMap();
    private Set<String> remove = new HashSet();
    private boolean clear = false;
    private ContentResolver cr;
    
    public REditor(ContentResolver paramContentResolver)
    {
      this.cr = paramContentResolver;
    }
    
    public SharedPreferences.Editor putString(String paramString1, String paramString2)
    {
      this.values.put(paramString1, paramString2);
      this.remove.remove(paramString1);
      return this;
    }
    
    public SharedPreferences.Editor putInt(String paramString, int paramInt)
    {
      this.values.put(paramString, Integer.valueOf(paramInt));
      this.remove.remove(paramString);
      return this;
    }
    
    public SharedPreferences.Editor putLong(String paramString, long paramLong)
    {
      this.values.put(paramString, Long.valueOf(paramLong));
      this.remove.remove(paramString);
      return this;
    }
    
    public SharedPreferences.Editor putFloat(String paramString, float paramFloat)
    {
      this.values.put(paramString, Float.valueOf(paramFloat));
      this.remove.remove(paramString);
      return this;
    }
    
    public SharedPreferences.Editor putBoolean(String paramString, boolean paramBoolean)
    {
      this.values.put(paramString, Boolean.valueOf(paramBoolean));
      this.remove.remove(paramString);
      return this;
    }
    
    public SharedPreferences.Editor remove(String paramString)
    {
      this.remove.add(paramString);
      return this;
    }
    
    public SharedPreferences.Editor clear()
    {
      this.clear = true;
      return this;
    }
    
    public boolean commit()
    {
      ContentValues localContentValues1 = new ContentValues();
      if (this.clear)
      {
        this.cr.delete(TencentColumns.CONTENT_URI, null, null);
        this.clear = false;
      }
      Object localObject1 = this.remove.iterator();
      while (((Iterator)localObject1).hasNext())
      {
      String   localObject2 = (String)((Iterator)localObject1).next();
        this.cr.delete(TencentColumns.CONTENT_URI, "key = ?", new String[] { localObject2 });
      }
      Object localObject2 = this.values.entrySet().iterator();
      while (((Iterator)localObject2).hasNext())
      {
        localObject1 = (Map.Entry)((Iterator)localObject2).next();
        Object localObject3 = ((Map.Entry)localObject1).getValue();
        ContentValues localContentValues2 = localContentValues1;
        Object localObject4 = null;

        int i=0;
        localContentValues2.put("type", Integer.valueOf(i));
        localContentValues2.put("value", localObject3.toString());
        if (((i = (localObject4 instanceof Double) ? 6 : (localObject4 instanceof Float) ? 5 : (localObject4 instanceof Boolean) ? 4 : (localObject4 instanceof String) ? 3 : (localObject4 instanceof Long) ? 2 : (localObject4 instanceof Integer) ? 1 : (localObject4 = localObject3) == null ? 0 : 0) == 0 ? 0 : 1) != 0) {
          this.cr.update(TencentColumns.CONTENT_URI, localContentValues1, "key = ?", new String[] { (String)((Map.Entry)localObject1).getKey() });
        }
      }
      return true;
    }
    
    public void apply() {}
    
    public SharedPreferences.Editor putStringSet(String paramString, Set<String> paramSet)
    {
      return null;
    }
  }
}



/* Location:           C:\Users\Mr Ding\Desktop\Android_SDK_5.0.6\libs\wechat-sdk-android-without-mta-1.3.4.jar

 * Qualified Name:     com.tencent.mm.opensdk.openapi.MMSharedPreferences

 * JD-Core Version:    0.7.0.1

 */